home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / recio202.zip / rput.c < prev    next >
C/C++ Source or Header  |  1994-05-05  |  2KB  |  50 lines

  1. /*****************************************************************************
  2.    MODULE: rput.c
  3.   PURPOSE: recio output functions
  4. COPYRIGHT: (C) 1994 William Pierpoint
  5.  COMPILER: Borland C Version 3.1
  6.        OS: MSDOS Version 6.2
  7.   VERSION: 2.02
  8.   RELEASE: May 5, 1994
  9. *****************************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14.  
  15. #include "recio.h"
  16.  
  17. extern int _rstatus(REC *rp, int mode);
  18. extern int _rputc(REC *rp, int ch);
  19.  
  20. #define rcol(rp)    ((rp)->r_colno)
  21.  
  22. /****************************************************************************/
  23. int                          /* return error (0=no error; !0=error)         */
  24.     rputrec(                 /* put end-of-record (newline) to stream       */
  25.         REC *rp)             /* record pointer                              */
  26. /****************************************************************************/
  27. {
  28.     int err=EOF;             /* return error (0=no error; !0=error) */
  29.  
  30.     if (!_rstatus(rp, R_WRITE)) {
  31.         err = _rputc(rp, '\n');
  32.         rcol(rp)=0;
  33.         rfldno(rp)=0;
  34.         rrecno(rp)++;
  35.     }
  36.     return err;
  37. }
  38.  
  39. /****************************************************************************/
  40. char *                       /* return pointer to string                    */
  41.     dtoa(                    /* convert floating point number to string     */
  42.         double d,            /* number to convert                           */
  43.         int    dig,          /* number of significant digits                */
  44.         char  *str)          /* string buffer to use                        */
  45. /****************************************************************************/
  46. {
  47.     sprintf(str, "%.*G", dig, d);
  48.     return str;
  49. }
  50.